home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-06-28 | 3.3 KB | 92 lines | [TEXT/CWIE] |
- // RedBlackLink.h
-
- #ifndef RedBlackLink_h
- #define RedBlackLink_h
-
- #ifndef RedBlackKey_h
- #include "RedBlackKey.h"
- #endif
- #ifndef Link_h
- #include "Link.h"
- #endif
-
- template < class Key, class Content > class RedBlackLinkTree;
- template < class Key, class Content > class RedBlackTreeLoop;
-
- template < class KeyType, class ContentType >
- class RedBlackLink: private RedBlackKey<KeyType>,
- public Link<ContentType>
- {
- friend class RedBlackLinkTree< KeyType, ContentType >;
- friend class RedBlackTreeLoop< KeyType, ContentType >;
-
- typedef RedBlackLink< KeyType, ContentType > Node;
- typedef RedBlackLinkTree< KeyType, ContentType > TreeType;
- typedef RedBlackKey<KeyType> NodeBase;
- typedef RedBlackKeyTree<KeyType> TreeBase;
-
- private:
- static Node *DownCast( NodeBase *n ) { return static_cast< Node* >( n ); }
- static const Node *DownCast( const NodeBase *n ) { return static_cast< const Node* >( n ); }
-
- static TreeType& DownCast( TreeBase& n );
- static const TreeType& DownCast( const TreeBase& n );
-
- public:
- RedBlackLink( const KeyType& theKey, ContentType *theContent = 0 )
- : RedBlackKey<KeyType>( theKey ),
- Link<ContentType>( theContent )
- {}
-
- NodeBase::Key;
- NodeBase::SetKey;
-
- NodeBase::Owned;
- TreeType& Owner() { return DownCast( NodeBase::Owner() ); }
- const TreeType& Owner() const { return DownCast( NodeBase::Owner() ); }
-
- Node *Parent() { return DownCast( NodeBase::Parent() ); }
- const Node *Parent() const { return DownCast( NodeBase::Parent() ); }
-
- Node *Left() { return DownCast( NodeBase::Left() ); }
- const Node *Left() const { return DownCast( NodeBase::Left() ); }
-
- Node *Right() { return DownCast( NodeBase::Right() ); }
- const Node *Right() const { return DownCast( NodeBase::Right() ); }
-
- Node *Next() { return DownCast( NodeBase::Next() ); }
- const Node *Next() const { return DownCast( NodeBase::Next() ); }
-
- Node *Previous() { return DownCast( NodeBase::Previous() ); }
- const Node *Previous() const { return DownCast( NodeBase::Previous() ); }
-
- Node *Sibling() { return DownCast( NodeBase::Sibling() ); }
- const Node *Sibling() const { return DownCast( NodeBase::Sibling() ); }
-
- bool operator==( const Node& n ) const { return NodeBase::operator==(n); }
- bool operator!=( const Node& n ) const { return NodeBase::operator!=(n); }
- bool operator>=( const Node& n ) const { return NodeBase::operator>=(n); }
- bool operator<=( const Node& n ) const { return NodeBase::operator<=(n); }
- bool operator>( const Node& n ) const { return NodeBase::operator>(n); }
- bool operator<( const Node& n ) const { return NodeBase::operator<(n); }
-
- bool operator==( const KeyType& n ) const { return NodeBase::operator==(n); }
- bool operator!=( const KeyType& n ) const { return NodeBase::operator!=(n); }
- bool operator>=( const KeyType& n ) const { return NodeBase::operator>=(n); }
- bool operator<=( const KeyType& n ) const { return NodeBase::operator<=(n); }
- bool operator>( const KeyType& n ) const { return NodeBase::operator>(n); }
- bool operator<( const KeyType& n ) const { return NodeBase::operator<(n); }
-
- NodeBase::IsRoot;
- NodeBase::IsLeftChild;
- NodeBase::IsRightChild;
-
- NodeBase::HasLeftChild;
- NodeBase::HasRightChild;
- NodeBase::IsLeaf;
-
- NodeBase::Depth;
- };
-
- #endif
-